package com.dhcc.bpm.business.papc.service.impl;

//import com.baomidou.dynamic.datasource.annotation.DS;
import com.dhcc.bpm.business.papc.entity.ChnlInfo;
import com.dhcc.bpm.business.papc.vo.ChnlInfoVO;
import com.dhcc.bpm.business.papc.mapper.ChnlInfoMapper;
import com.dhcc.bpm.business.papc.service.IChnlInfoService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.util.StringUtils;
import java.util.List;

/**
 * 中间业务渠道信息表  服务实现类
 *
 * @author liuzhao
 * @since 2020-05-16
 */
@Service
//@DS("slave")
public class ChnlInfoServiceImpl extends BaseServiceImpl<ChnlInfoMapper, ChnlInfo> implements IChnlInfoService {

    @Override
    public IPage<ChnlInfoVO> selectChnlInfoPage(IPage<ChnlInfoVO> page, ChnlInfoVO chnlInfo) {
        return page.setRecords(baseMapper.selectChnlInfoPage(page, chnlInfo));
    }

    @Override
    public ChnlInfo seletChnlInfoById(Long id) {
        return baseMapper.selectChnlInfoById(id);
    }

    @Override
    public boolean saveOrUpdate(ChnlInfo chnlInfo) {
        int result;
        if (StringUtils.isEmpty(chnlInfo.getId())) {
            result = baseMapper.save(chnlInfo);
        } else {
            chnlInfo.setChnlInfoKey(chnlInfo.getId().toString());
            result = baseMapper.update(chnlInfo);
        }
        return result >= 1;
    }

    @Override
    public boolean deleteChnlInfoByIds(String ids) {
        int result = baseMapper.deleteChnlInfoByIds(ids.split(","));
        return result >= 1;
    }

    @Override
    public List<ChnlInfo> selectChnlInfoAll(ChnlInfo chnlInfo) {
        return baseMapper.selectChnlInfoAll(chnlInfo);
    }

}
